package com.xkcoding.orm.jdbctemplate.Clickhousejdbctemplate.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.xkcoding.orm.jdbctemplate.Clickhousejdbctemplate.common.jdbcTemplate.CilckhouseDataWorker;
import com.xkcoding.orm.jdbctemplate.Clickhousejdbctemplate.common.jdbcTemplate.DataWorker;
import com.xkcoding.orm.jdbctemplate.Clickhousejdbctemplate.common.properties.ClickHoseProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class CollecionConfig {

    @Autowired
    private ClickHoseProperties clickHoseProperties;

    @Bean(name = "cilckhouse")
    public DataWorker dataWorker() {
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(clickHoseProperties.getUrl());
        datasource.setDriverClassName(clickHoseProperties.getDriverClassName());
        datasource.setInitialSize(clickHoseProperties.getInitialSize());
        datasource.setMinIdle(clickHoseProperties.getMinIdle());
        datasource.setMaxActive(clickHoseProperties.getMaxActive());
        datasource.setMaxWait(clickHoseProperties.getMaxWait());
        datasource.setUsername(clickHoseProperties.getUsername());
        datasource.setPassword(clickHoseProperties.getPassword());
        return new CilckhouseDataWorker(datasource);
    }

}
